﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AllCardManage.aspx.cs" Inherits="SDLITS.Web.Driver.AllCardManage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>会员卡重置</title>
     <link href="../js/uploadify/uploadify.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery-1.4.1.min.js" type="text/javascript"> </script>
    <script type="text/javascript" src="../js/uploadify/jquery.uploadify-3.1.min.js"></script>
    <style type="text/css">
        .customlabel span {
            color: red;
            font-weight: bold;
        }
        .marginright { margin-right:15px;}
    </style>
</head>
<body onload="init()">
    <object id="CardReader1" codebase="../FirstActivex.cab#version=1,3,3,1" classid="CLSID:F225795B-A882-4FBA-934C-805E1B2FBD1B" width="0" height="0">
        <param name="_Version" value="65536" />
        <param name="_ExtentX" value="2646" />
        <param name="_ExtentY" value="1323" />
        <param name="_StockProps" value="0" />
        <param name="port" value="串口1" />
        <param name="PhotoPath" value="" />
        <param name="ActivityLFrom" value="" />
        <param name="ActivityLTo" value="" />
    </object>
    <object classid="CLSID:4E16E1BD-B562-48E3-813E-DC5CA566D94C" codebase="../MXOTOCX.ocx"
        id="fpDevObj" height="0" width="0">
    </object>
    <form id="form1" runat="server">
        <f:PageManager ID="PageManager1" runat="server" />
        <f:Panel ID="Panel1" BodyPadding="5px" runat="server" EnableCollapse="false" Title="会员卡管理" ShowBorder="false">
            <Toolbars>
                <f:Toolbar ID="spanActions" Hidden="true" runat="server">
                    <Items>
                        <f:Button runat="server" ID="lbtnAddDriverCard" Hidden="true" OnClick="lbtnAddDriverCard_Click" Text="办理驾驶员卡"></f:Button>
                        <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                        <f:Button runat="server" ID="lbtnAddTempCard" Hidden="true" OnClick="lbtnAddTempCard_Click" Text="办理临时卡"></f:Button>
                        <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                        <f:Button runat="server" ID="lbtnModifyCard" Hidden="true" OnClick="lbtnModifyCard_Click" Text="更新(换)卡"></f:Button>
                        <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                        <f:Button runat="server" ID="lbtnFreeCard" Hidden="true" OnClick="lbtnFreeCard_Click" Text="销卡"></f:Button>
                        <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                        <f:Button runat="server" ID="lbtnUpdateCard" Hidden="true" OnClick="lbtnUpdateCard_Click" Text="升级卡"></f:Button>
                        <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                        <f:Button runat="server" ID="lbtnSubmitDriver" Hidden="true" OnClick="lbtnSubmitDriver_Click" Text="提交"></f:Button>
                        <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                        <f:Button runat="server" ID="lbtnSubmitTemp" Hidden="true" OnClick="lbtnSubmitTemp_Click" Text="提交"></f:Button>
                        <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                        <f:Button runat="server" ID="Button1" OnClick="Button1_Click" Text="取消"></f:Button>
                    </Items>
                </f:Toolbar>
            </Toolbars>
            <Items>
                <f:GroupPanel ID="GroupPanel5" Title="卡功能" runat="server" Height="55px" Width="800px" EnableCollapse="false">
                    <Items>
                        <f:Panel ID="Panel2" Layout="Column"  ShowHeader="false" ShowBorder="false" runat="server">
                            <Items>
                                <f:Button runat="server" ID="lbtnReadIDCard" OnClick="btnReset_Click" CssClass="marginright" Text="读取身份证"></f:Button>
                                <f:Button runat="server" ID="lbtnWriteIDCard" OnClick="btnReset_Click" Text="输入身份证"></f:Button>
                            </Items>
                        </f:Panel>                           
                    </Items>
                </f:GroupPanel>
                <f:GroupPanel runat="server" Title="个人身份证信息" ID="spanIdentity"  Width="800px" EnableCollapse="True">
                    <Items>
                        <f:Panel ID="Panel3" runat="server" Height="170px" Width="800px" ShowBorder="false" ShowHeader="false"
                            Layout="HBox" BoxConfigAlign="Stretch" BoxConfigPosition="Start" BoxConfigChildMargin="0 40 0 0">
                            <Items>
                                <f:Panel ID="Panel4" Title="面板1" BoxFlex="1" runat="server" BodyPadding="5px" ShowBorder="false" ShowHeader="false">
                                    <Items>
                                        <f:SimpleForm ID="SimpleForm1" runat="server" LabelWidth="70px" ShowBorder="False" ShowHeader="False">
                                            <Items>
                                                <f:TextBox ID="lblIDNumber" Label="身份证号" runat="server"></f:TextBox>
                                                <f:TextBox ID="lblName" Label="姓名" runat="server"></f:TextBox>
                                                <f:TextBox ID="lblIDAddress" Label="地址" runat="server"></f:TextBox>
                                                <f:TextBox ID="lblSex" Label="性别" runat="server"></f:TextBox>
                                                <f:DatePicker runat="server" EnableEdit="false" DateFormatString="yyyy-MM-dd" Label="出生年月" ID="lblBirthday"></f:DatePicker>
                                            </Items>
                                        </f:SimpleForm>
                                    </Items>
                                </f:Panel>
                                <f:Panel ID="Panel5" Title="面板2" Width="350px" runat="server" BodyPadding="5px" ShowBorder="false" ShowHeader="false">
                                    <Items>
                                        <f:SimpleForm ID="SimpleForm5" runat="server" LabelWidth="80px" ShowBorder="False" ShowHeader="False">
                                            <Items>
                                                <f:Image Width="102px" Height="126px" runat="server" ID="imgIDShot" Label="身份证照片"></f:Image>
                                            </Items>
                                        </f:SimpleForm>
                                    </Items>
                                </f:Panel>
                            </Items>
                        </f:Panel>
                    </Items>
                </f:GroupPanel>
                <f:GroupPanel ID="spanDataList" Title="卡记录" runat="server" Hidden="true" Height="205px" Width="800px" EnableCollapse="false">
                    <Items>
                        <f:Panel ID="Panel6" Title="管理" ShowBorder="false" BodyPadding="0" ShowHeader="false" Layout="Fit" runat="server" AutoScroll="true">
                            <Items>
                                <f:Grid ID="Grid1" ShowBorder="false" PageSize="5" AllowPaging="true" EnableCheckBoxSelect="true" IsDatabasePaging="false"
                                     OnPageIndexChange="Grid1_PageIndexChange" OnRowDataBound="Grid1_RowDataBound" EnableColumnLines="true" EnableHeaderMenu="false" ShowHeader="false" Title="表格" Width="760px" runat="server"
                                     EnableCollapse="false" DataKeyNames="MemCardNo">
                                    <Columns>
                                        <f:RowNumberField EnablePagingNumber="true" Width="80px" TextAlign="Center" />
                                        <f:BoundField Width="80px" DataField="MemCardNo" HeaderText="卡号" />
                                        <f:BoundField Width="60px" DataField="MemType" HeaderText="卡类型" />
                                        <f:BoundField Width="60px" DataField="StatusID" HeaderText="状态" />
                                        <f:BoundField Width="80px" DataField="RegistID" HeaderText="会员卡号" />
                                        <f:BoundField Width="80px" DataField="Name" HeaderText="会员名" />
                                        <f:BoundField Width="80px" DataField="LeftCash" HeaderText="剩余金额" />
                                        <f:BoundField Width="100px" DataField="StartDate" DataFormatString="{0:yyyy-MM-dd}" HeaderText="开始日期" />
                                        <f:BoundField Width="100px" DataField="ExpireDate" DataFormatString="{0:yyyy-MM-dd}" HeaderText="过期日期" />
                                    </Columns>
                                </f:Grid>
                            </Items>
                        </f:Panel>                           
                    </Items>
                </f:GroupPanel>
                <f:GroupPanel runat="server" Title="个人信息" ID="dataPersonal" Hidden="true"  Width="800px" EnableCollapse="True">
                    <Items>
                        <f:Panel ID="Panel7" runat="server" Width="800px" ShowBorder="false" ShowHeader="false"
                            Layout="HBox" BoxConfigAlign="Stretch" BoxConfigPosition="Start" BoxConfigChildMargin="0 40 0 0">
                            <Items>
                                <f:Panel ID="Panel8" Title="面板1" BoxFlex="1" runat="server" BodyPadding="5px" ShowBorder="false" ShowHeader="false">
                                    <Items>
                                        <f:SimpleForm ID="SimpleForm2" runat="server" LabelWidth="70px" ShowBorder="False" ShowHeader="False">
                                            <Items>
                                                <f:TextBox ID="txtCell" Label="手机号码" runat="server"></f:TextBox>
                                                <f:TextBox ID="txtPhone" Label="座机号码" runat="server"></f:TextBox>
                                                <f:TextArea ID="txtCustom1" Height="88px" Label="备注1" runat="server"></f:TextArea>
                                                <f:TextArea ID="txtCustom2" Height="88px" Label="备注2" runat="server"></f:TextArea>
                                                <f:Button runat="server" ID="btnGetimg" OnClientClick="Button_GetImage()" EnablePostBack="false" Text="读取指纹"></f:Button>
                                            </Items>
                                        </f:SimpleForm>
                                    </Items>
                                </f:Panel>
                                <f:Panel ID="Panel9" Title="面板2" Width="350px" runat="server" BodyPadding="5px" ShowBorder="false" ShowHeader="false">
                                    <Items>
                                        <f:SimpleForm ID="SimpleForm3" runat="server" LabelWidth="80px" ShowBorder="False" ShowHeader="False">
                                            <Items>
                                                <f:Image Width="102px" Height="126px" runat="server" ID="imgFinger" Label="指纹照片"></f:Image>
                                            </Items>
                                        </f:SimpleForm>
                                    </Items>
                                </f:Panel>
                            </Items>
                        </f:Panel>
                    </Items>
                </f:GroupPanel>
                <f:GroupPanel ID="dataCard" Title="卡信息" Hidden="true" Width="800px" runat="server" EnableCollapse="True">
                    <Items>
                        <f:Form ID="SimpleForm10" BodyPadding="5px" runat="server" LabelWidth="70px" ShowBorder="False" ShowHeader="False">
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:FileUpload runat="server" ButtonText="上传" AutoPostBack="true" OnFileSelected="file_upload_FileSelected" ButtonOnly="true" Label="上传照片" ID="file_upload"></f:FileUpload>
                                        <f:Image Width="102px" Height="126px" runat="server" ID="imgCam" Label="拍摄照片"></f:Image>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:TextBox ID="txtMemCardNo" Label="出入卡号" runat="server">
                                        </f:TextBox>
                                        <f:Label ID="lblMemType" Hidden="true" Label="卡类型" runat="server">
                                        </f:Label>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:Label ID="Label1" Label="卡类型" runat="server">
                                        </f:Label>
                                        <f:TextBox ID="TextBox1" Hidden="true" Label="出入卡号" runat="server">
                                        </f:TextBox>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:DatePicker ID="txtStartDate" runat="server" EnableEdit="false" Label="开始日期"></f:DatePicker>
                                        <f:Label ID="lblExpireDate11" Hidden="true" Label="过期日期" runat="server"></f:Label>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:Label ID="lblExpireDate" Label="过期日期" runat="server"></f:Label>
                                        <f:DatePicker ID="DatePicker1" Hidden="true" runat="server" EnableEdit="false" Label="开始日期"></f:DatePicker>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:Label ID="lblLeftCash" Label="剩余现金" runat="server">
                                        </f:Label>
                                        <f:TextBox ID="TextBox15" Hidden="true" Label="名称" runat="server">
                                        </f:TextBox>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                        </f:Form>
                    </Items>
                </f:GroupPanel>
                <f:GroupPanel ID="dataDriverCardInfo" Hidden="true" Title="驾驶证信息" Width="800px" runat="server" EnableCollapse="True">
                    <Items>
                        <f:Form ID="Form2" BodyPadding="5px" runat="server" LabelWidth="80px" ShowBorder="False" ShowHeader="False">
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:TextBox ID="txtDLName" Label="驾驶员姓名" runat="server">
                                        </f:TextBox>
                                        <f:RadioButtonList ID="rbtnDLSex" Label="驾驶员性别" ColumnNumber="5" runat="server">
                                            <f:RadioItem Text="男" Value="yinlian" Selected="true" />
                                            <f:RadioItem Text="女" Value="visa" />
                                        </f:RadioButtonList>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:TextBox ID="txtDLNumber" Label="驾照号码" runat="server">
                                        </f:TextBox>
                                        <f:TextBox ID="txtDLAddress" Label="驾照地址" runat="server">
                                        </f:TextBox>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                        </f:Form>
                    </Items>
                </f:GroupPanel>
                <f:GroupPanel ID="dataRunCardInfo" Hidden="true" Title="行驶证信息" Width="800px" runat="server" EnableCollapse="True">
                    <Items>
                        <f:Form ID="Form3" BodyPadding="5px" runat="server" LabelWidth="80px" ShowBorder="False" ShowHeader="False">
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:TextBox ID="txtCarNo" Label="车牌号" runat="server">
                                        </f:TextBox>
                                        <f:TextBox ID="txtCarEnginNo" Label="发动机号" runat="server">
                                        </f:TextBox>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:TextBox ID="txtCarIDNo" Label="车标识号" runat="server">
                                        </f:TextBox>
                                        <f:TextBox ID="txtCarOwnerName" Label="车主姓名" runat="server">
                                        </f:TextBox>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:TextBox ID="txtCarOwnerAddr" Label="车主地址" runat="server">
                                        </f:TextBox>
                                        <f:TextBox ID="txtGCarNo" Label="挂车号码" runat="server">
                                        </f:TextBox>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:TextBox ID="txtGCarIDNo" Label="挂车标识号" runat="server">
                                        </f:TextBox>
                                        <f:TextBox ID="TextBox23" Hidden="true" Label="驾照地址" runat="server">
                                        </f:TextBox>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                        </f:Form>
                    </Items>
                </f:GroupPanel>
            </Items>
        </f:Panel>
        <f:HiddenField runat="server" ID="hidMapPath1"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidMapPath1p"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidIDShotTimesnap"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidMapPath2"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidMapPath2p"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidFingerShotTimesnap"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidMapPath3"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidMapPath3p"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidCamShotTimesnap"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidCamShotName"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidFingerShotName"></f:HiddenField>
    </form>
</body>
</html>
<script type="text/javascript">
    
    function init() {
        var obj = document.getElementById("CardReader1");
        obj.setPortNum(0);
    }
    function GetRealTime() {
        var myDate = new Date();
        return String(myDate.getFullYear()) + String(myDate.getMonth() + 1) +
            String(myDate.getDate()) + String(myDate.getHours()) + String(myDate.getMinutes()) +
                String(myDate.getSeconds()) + String(myDate.getMilliseconds());
    }

    function readCard() {
        var obj = document.getElementById("CardReader1");
        obj.Flag = 1;

        var timesnap = '<%= hidIDShotTimesnap.ClientID %>';
        var mappath1p = '<%= hidMapPath1p.ClientID %>';
        $("#"+timesnap).val(GetRealTime());
        obj.PhotoPath = $("#" + mappath1p).val() + $("#" + timesnap).val() + "\\";

        var fso;
        fso = new ActiveXObject("Scripting.FileSystemObject");
        fso.CreateFolder(obj.PhotoPath);

        //alert(obj.PhotoPath);
        obj.ReadCard();

        var IDNumber = '<%= lblIDNumber.ClientID %>';
        var lblSex = '<%= lblSex.ClientID %>';
        var lblName = '<%= lblName.ClientID %>';
        var lblBirthday = '<%= lblBirthday.ClientID %>';
        var lblIDAddress = '<%= lblIDAddress.ClientID %>';
        $("#"+IDNumber).val(obj.CardNo.trim());
        if (obj.Sex.trim() == "1") {
            $("#"+lblSex).val("男");
        }
        else if (obj.Sex.trim() == "0") {
            $("#" + lblSex).val("女");
        }
        else {
            $("#" + lblSex).val("");
        }

        $("#"+lblName).val(obj.Name.trim());
        if (obj.Born.trim() != "") {
            var oldDate = obj.Born.trim();
            var newDate = String.format("{0}-{1}-{2}", oldDate.substring(0, 4), oldDate.substring(4, 6), oldDate.substring(6, 8));
            $("#"+lblBirthday).val(newDate);
        }
        else {
            $("#"+lblBirthday).val("");
        }

        $("#"+lblIDAddress).val(obj.Address.trim());
    }

    var dwWaitTime = 5000; //超时时间（毫秒）
    var error1 = "打开指纹仪失败";
    var error2 = "用户取消操作";
    var error3 = "等待手指超时";
    var error4 = "采集图像失败";
    var error5 = "上传图像失败";
    var error6 = "提取指纹特征失败";
    var error7 = "合并指纹模板失败";

    function Button_Check_Device() {
        var bFlag = window.fpDevObj.IsMxUsbDevice();
        if (bFlag == "-1") {
            alert("连接失败");
            return;
        }
        else {
            alert("连接成功");
            return;
        }
    }
    var hidFingerShotTimesnap = '<%= hidFingerShotTimesnap.ClientID %>';
    var hidMapPath2p = '<%= hidMapPath2p.ClientID %>';
    var lblIDNumber = '<%= lblIDNumber.ClientID %>';
    var imgFinger = '<%= imgFinger.ClientID %>';
    var hidMapPath2 = '<%= hidMapPath2.ClientID %>';
    var hidFingerShotName = '<%= hidFingerShotName.ClientID %>';
    var imgCam = '<%= imgCam.ClientID %>';
    var hidMapPath3 = '<%= hidMapPath3.ClientID %>';
    var hidCamShotTimesnap = '<%= hidCamShotTimesnap.ClientID %>';
    var hidCamShotName = '<%= hidCamShotName.ClientID %>';
    
    function Button_GetImage() {
        
        $("#"+hidFingerShotTimesnap).val(GetRealTime());
        var img = window.fpDevObj.mxUsbGetImage(dwWaitTime);
        if (img == "-1") {
            alert(error1);
            return false;
        }
        else if (img == "-2") {
            alert(error2);
            return false;
        }
        else if (img == "-3") {
            alert(error3);
            return false;
        }
        else if (img == "-4") {
            alert(error4);
            return false;
        }
        else if (img == "-5") {
            alert(error5);
            return false;
        }
        else {
            window.fpDevObj.mxImageToFile($("#"+hidMapPath2p).val() + $("#"+lblIDNumber).val() + $("#"+hidFingerShotTimesnap).val() + ".bmp", img);
            $("#"+imgFinger).attr("src", $("#"+hidMapPath2).val() + $("#"+lblIDNumber).val() + $("#"+hidFingerShotTimesnap).val() + ".bmp");
            $("#"+hidFingerShotName).val($("#"+lblIDNumber).val() + $("#"+hidFingerShotTimesnap).val() + ".bmp");
        }
        return true;
    }
    /*function DocumentReady() {
        $(function () {
            $("#file_upload_1").uploadify({
                height: 22,
                swf: '../js/uploadify/uploadify.swf',
                uploader: '/CommonClass/UploadHandler.ashx?id=' + $("#"+lblIDNumber).val() + $("#"+hidCamShotTimesnap).val(),
                width: 100,
                buttonText: "选择摄像头照片",
                fileTypeExts: "*.jpg",
                buttonCursor: "hand",
                onUploadComplete: function (file) {
                    $("#"+imgCam).attr("src", $("#"+hidMapPath3).val() + $("#"+lblIDNumber).val() + $("#"+hidCamShotTimesnap).val() + ".jpg?random=" + (new Date()).getTime());
                    $("#"+hidCamShotName).val($("#"+lblIDNumber).val() + $("#"+hidCamShotTimesnap).val() + ".jpg");
                }
            });
        });
    }

    $(document).ready(DocumentReady);*/

    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(DocumentReady);
</script>